<div class="fm-content">
  <div class="title">
    <i nz-icon [type]="'desktop'"></i>
    &nbsp;&nbsp;友情链接
  </div>
  <div class="clwork">
    <div class="top">
      <input nz-input placeholder="名称" class="fm-input first-input" [(ngModel)]="fs.queryObject['linkname:like']" />
      <nz-button-group class="fm-search-input">
        <button nz-button nzType="primary" (click)="fs.loadData(true)">查询</button>
        <button nz-button (click)="fs.resetQueryObject() && fs.loadData(true)">重置</button>
      </nz-button-group>
      <div class="tool-right">
        <nz-button-group>
          <button nz-button [nzType]="'primary'" (click)="fs.addRow()">新增</button>
          <button nz-button (click)="fs.editRow()">编辑</button>
          <button nz-popconfirm nzTitle="确认删除选择项?" (nzOnConfirm)="fs.delEntitys()" nzPlacement="bottomRight"
            nz-button>删除</button>
        </nz-button-group>
      </div>
    </div>

    <div class="left top-left">
      <nz-tree nzAsyncData (nzClick)="fs.loadDataEx($event.node.key)" [nzData]="sideDic.treeDatas"
        (nzExpandChange)="sideDic.expand($event)">
      </nz-tree>
    </div>

    <div class="right top-right">
      <div class="table">
        <nz-table nzSize="middle" nzShowSizeChanger [nzPageSizeOptions]='[ 10, 15, 20, 30, 40, 50 ]'
          [nzFrontPagination]="false" [nzData]="fs.datas" [nzLoading]="fs.isLoading || fs.isDeleing"
          [nzTotal]="fs.rowsCount" [(nzPageIndex)]="fs.pageIndex" [(nzPageSize)]="fs.pageSize"
          (nzPageIndexChange)="fs.loadData()" (nzPageSizeChange)="fs.loadData(true)">
          <thead>
            <tr>
              <th nzShowCheckbox [(nzChecked)]="fs.allChecked" [nzIndeterminate]="fs.indeterminate"
                (nzCheckedChange)="fs.checkAll($event)"></th>
              <th nzWidth="20%">名称</th>
              <th nzWidth="20%">地址</th>
              <th nzWidth="20%">站长邮件</th>
              <th nzWidth="20%">推荐</th>
              <th nzWidth="20%">是否有效</th>
            </tr>
          </thead>
          <tbody>
            <tr *ngFor="let data of fs.datas">
              <td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="fs.refreshCheckStatus()">
              </td>
              <td><span (click)="fs.editRow(data)" class="form-edit">{{data.linkName}}</span></td>
              <td>{{data.linkAddress}}</td>
              <td>{{data.email}}</td>
              <td>{{data.recommend | boolReform}}</td>
              <td>{{data.valid | boolReform}}</td>
            </tr>
          </tbody>
        </nz-table>
      </div>
    </div>

    <nz-modal nzWidth='830' nzTitle="编辑" [nzMaskClosable]='false' [nzFooter]="null" [(nzVisible)]="fs.isEditVisible"
      (nzOnCancel)="fs.closeEdit()">
      <form nz-form [nzLayout]="'inline'">
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">名称</nz-form-label>
              <nz-form-control class="form-control3" [nzValidateStatus]="linkname.invalid?'error':'success'"
                nzHasFeedback>
                <input nz-input [(ngModel)]="fs.er.linkName" name="linkname" required #linkname="ngModel" />
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">地址</nz-form-label>
              <nz-form-control class="form-control3" [nzValidateStatus]="linkaddress.invalid?'error':'success'"
                nzHasFeedback>
                <input nz-input [(ngModel)]="fs.er.linkAddress" name="linkaddress" required #linkaddress="ngModel" />
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24">
            <nz-form-item>
              <nz-form-label class="form-label">图片</nz-form-label>
              <nz-form-control class="form-control3">
                <nz-upload nzAction="{{ ffs.getUploadUrl() }}" nzListType="picture-card"
                  [(nzFileList)]="fs.er.pictureAddress" [nzAccept]="'.png,.jpg'"
                  [nzShowButton]="fs.er.pictureAddress ? fs.er.pictureAddress.length < 1 : true" [nzShowUploadList]="{ showPreviewIcon: true,
                                        showRemoveIcon: true,
                                        hidePreviewIconInNonImage: true }" (nzChange)="ffs.handleChange($event)"
                  [nzPreview]="ffs.handlePreview">
                  <i nz-icon type="plus"></i>
                  <div class="ant-upload-text">上传</div>
                </nz-upload>
                <!-- 放大查看 -->
                <nz-modal [nzVisible]="ffs.previewVisible" [nzContent]="modalContent" [nzFooter]="null"
                  (nzOnCancel)="ffs.previewVisible = false">
                  <ng-template #modalContent>
                    <img [src]="ffs.previewImage" [ngStyle]="{ width: '100%' }" />
                  </ng-template>
                </nz-modal>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24">
            <nz-form-item>
              <nz-form-label class="form-label">站长邮件</nz-form-label>
              <nz-form-control class="form-control3">
                <input nz-input [(ngModel)]="fs.er.email" name="email" />
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24">
            <nz-form-item>
              <nz-form-label class="form-label">网站描述</nz-form-label>
              <nz-form-control class="form-control3">
                <input nz-input [(ngModel)]="fs.er.describe" name="describe" />
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">排序</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="order.invalid?'error':'success'" nzHasFeedback>
                <nz-input-number [(ngModel)]="fs.er.order" name="order" required #order="ngModel" [nzMin]="1"
                  [nzMax]="100" [nzStep]="1" class="form-control">
                </nz-input-number>
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label class="form-label">属性</nz-form-label>
              <nz-form-control class="form-control">
                <label nz-checkbox [(ngModel)]="fs.er.recommend" name="valid">推荐</label>
                <label nz-checkbox [(ngModel)]="fs.er.valid" name="valid">有效</label>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24" class="form-button-align">
            <button nz-button nzType="default" (click)="fs.closeEdit()" class="form-button">取消</button>
            <button nz-button nzType="primary" [disabled]='order.invalid || linkname.invalid || linkaddress.invalid'
              (click)="fs.save()" [nzLoading]="fs.isSaveing">保存</button>
          </div>
        </div>
      </form>
    </nz-modal>
  </div>
</div>
